<template>
  <div class="inputSearch">
    <div class="inputDiv" style="margin-top: 15px">
      <el-input
        placeholder="请输入内容"
        v-model="input3"
        class="input-with-select"
        @change="onChange"
      >
        <el-button slot="append" icon="el-icon-search"></el-button>
      </el-input>
      <el-button type="primary" @click="onAdd">添加商品</el-button>
    </div>
  </div>
</template>

<script>
import user from "@/api/user";
export default {
  name: "inputSearch",
  data() {
    return {
      input1: "",
      input2: "",
      input3: "",
      select: "",
      arrList: [],
    };
  },
  methods: {
    onChange(res) {
      let obj = {
        pagenum: 1,
        pagesize: 1000,
      };
      user.getCategories(obj).then((val) => {
        let _this = this;
        let goodsList = val.data.data.goods;
        for (var i = 0; i < goodsList.length; i++) {
          if (goodsList[i].goods_name.indexOf(res) != -1) {
            _this.arrList.push(goodsList[i]);
          }
        }
      });
      this.bus.$emit("arrlist", this.arrList);
    },
    onAdd() {
      this.$router.push("/home/goodsList/AddGoodCom");
    },
  },
};
</script>

<style>
.el-select .el-input {
  width: 130px;
}
.input-with-select {
  width: 400px;
  margin-right: 10px;
}
.input-with-select .el-input-group__prepend {
  background-color: #fff;
}
.inputDiv {
  width: 510px;
  padding: 10px 0;
}
</style>